package com.education.wisdom.service.impl;

import com.education.common.utils.Convert;
import com.education.common.utils.UUIDUtils;
import com.education.wisdom.mapper.QuestionsMapper;
import com.education.wisdom.pojo.Questions;
import com.education.wisdom.service.IQuestionsService;
import com.education.wisdom.vo.QuestionsVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * 试题 服务层实现
 * 
 * @author ruoyi
 * @date 2018-11-13
 */
@Service
public class QuestionsServiceImpl implements IQuestionsService
{
	@Autowired
	private QuestionsMapper questionsMapper;

	/**
     * 查询试题信息
     * 
     * @param stId 试题ID
     * @return 试题信息
     */
    @Override
	public Questions selectQuestionsById(String stId)
	{
	    return questionsMapper.selectQuestionsById(stId);
	}
	
	/**
     * 查询试题列表
     * 
     * @param questions 试题信息
     * @return 试题集合
     */
	@Override
	public List<Questions> selectQuestionsList(Questions questions)
	{
	    return questionsMapper.selectQuestionsList(questions);
	}
	
    /**
     * 新增试题
     * 
     * @param questions 试题信息
     * @return 结果
     */
	@Override
	public int insertQuestions(Questions questions)
	{
		questions.setStId(UUIDUtils.getByUUId());
		questions.setCreateTime(new Date());
		return questionsMapper.insertQuestions(questions);
	}
	
	/**
     * 修改试题
     * 
     * @param questions 试题信息
     * @return 结果
     */
	@Override
	public int updateQuestions(Questions questions)
	{
	    return questionsMapper.updateQuestions(questions);
	}

	/**
     * 删除试题对象
     * 
     * @param ids 需要删除的数据ID
     * @return 结果
     */
	@Override
	public int deleteQuestionsByIds(String ids)
	{
		return questionsMapper.deleteQuestionsByIds(Convert.toStrArray(ids));
	}

	@Override
	public int deleteQuestionsById(Integer id) {
		return questionsMapper.deleteQuestionsById(id);
	}

	@Override
	public List<QuestionsVo> selectQuestionsListById(Map<String, Object> map) {
		return questionsMapper.selectQuestionsListById(map);
	}

	@Override
	public Integer selectCount(Map<String, Object> map) {
		return questionsMapper.selectCount(map);
	}

	@Override
	public Integer selectCountByPaperId(Integer paperId) {
		return questionsMapper.selectCountByPaperId(paperId);
	}

	@Override
	public List<Questions> selectByPaperId(Integer id) {
		return questionsMapper.selectByPaperId(id,null);
	}

	@Override
	public List<Questions> selectByPaperId(Integer id, Integer type) {
		return questionsMapper.selectByPaperId(id,type);
	}

	@Override
	public String[] selectIdsByType(Integer type) {
		return questionsMapper.selectIdsByType(type);
	}

	@Override
	public String[] selectIdsByTypeCatalog(Integer type, Integer catalogId) {
		return questionsMapper.selectIdsByTypeCatalog(type,catalogId);
	}
}
